﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Com.ArHat.DAL;
using Com.ArHat.IDAL;

namespace Com.ArHat.BLL
{
   public class CommonService
    {
        private static readonly IDbSession DbSession = DbSessionFactory.GetCurrentDbSession();

        public static string ExecProcdure(string strModuleNo, string strCodeType, string strLoginId, string strCodeRule,
                                          string strBasicPrefix)
        {
            SqlParameter[] parameters =
                {
                    new SqlParameter("@ModuleNo", SqlDbType.VarChar),
                    new SqlParameter("@CodeType", SqlDbType.VarChar),
                    new SqlParameter("@LoginId", SqlDbType.VarChar),
                    new SqlParameter("@CodeRule", SqlDbType.VarChar),
                    new SqlParameter("@BasicPrefix", SqlDbType.VarChar),
                    new SqlParameter("@ReturnCode", SqlDbType.VarChar, 100)
                };
            parameters[0].Value = strModuleNo;
            parameters[1].Value = strCodeType;
            parameters[2].Value = strLoginId;
            parameters[3].Value = strCodeRule;
            parameters[4].Value = strBasicPrefix;
            parameters[5].Direction = ParameterDirection.Output;
            DbSession.ExcuteSql(
                @"EXEC proc_SysCodeRule @ModuleNo,@CodeType,@LoginId,@CodeRule,@BasicPrefix,@ReturnCode OUTPUT",
                parameters);
            if (parameters[5].Value == null)
                return "ERROR";
            else
                return parameters[5].Value.ToString().Trim();
        }

        public static IEnumerable<string> GetMenuName()
        {
            return DbSession.GetMenuName(@"EXEC TestProduct");
        }
     
    }
    }

